//package cc.vv.baselibrary.adapter.deliveryAddress;
//
//import android.content.Context;
//import android.content.Intent;
//import android.text.Html;
//import android.text.TextUtils;
//import android.view.View;
//import android.view.ViewGroup;
//import android.widget.ImageView;
//import android.widget.RelativeLayout;
//import android.widget.TextView;
//
//import java.util.ArrayList;
//import java.util.List;
//
//import cc.vv.baselibrary.R;
//import cc.vv.baselibrary.activity.deliveryAddress.SelectDeliveryAddressActivity;
//import cc.vv.baselibrary.adapter.LKBaseAdapter;
//import cc.vv.baselibrary.db.daTable.DeliveryAddressBean;
//import cc.vv.baselibrary.util.LKLogUtil;
//import cc.vv.baselibrary.util.StringProcessingUtil;
//
//
///**
// * 选择收货地址列表适配器
// * Created by sun.li on 2017/7/3.
// * @author sun.li
// */
//public class SelectedDeliveryAddressAdapter extends LKBaseAdapter<DeliveryAddressBean> {
//
//    public SelectedDeliveryAddressAdapter(Context context, List<DeliveryAddressBean> deliveryAddressBeanList) {
//        super(context, (ArrayList<DeliveryAddressBean>) deliveryAddressBeanList);
//    }
//
//    @Override
//    protected View lpgetView(int position, View convertView, ViewGroup parent) {
//        ViewHolder viewHolder;
//        if (convertView == null) {
//            viewHolder = new ViewHolder();
//            convertView = View.inflate(mContext, R.layout.layout_delivery_address_item, null);
//            viewHolder.rl_dai_selectAddress_layout = (RelativeLayout) convertView.findViewById(R.id.rl_dai_selectAddress_layout);
//            viewHolder.tv_dai_userName = (TextView) convertView.findViewById(R.id.tv_dai_userName);
//            viewHolder.tv_dai_phone = (TextView) convertView.findViewById(R.id.tv_dai_phone);
//            viewHolder.tv_dai_address = (TextView) convertView.findViewById(R.id.tv_dai_address);
//            viewHolder.iv_dai_selectAddress = (ImageView) convertView.findViewById(R.id.iv_dai_selectAddress);
//            convertView.setTag(viewHolder);
//        } else {
//            viewHolder = (ViewHolder) convertView.getTag();
//        }
//        initViewEvent(position, viewHolder);
//
//        return convertView;
//    }
//
//
//    private void initViewEvent(int i, final ViewHolder viewHolder) {
//        if (viewHolder != null && mObjList != null) {
//            final DeliveryAddressBean deliveryAddressBean = mObjList.get(i);
//            if (deliveryAddressBean != null) {
//                if (!TextUtils.isEmpty(deliveryAddressBean.getUserName())) {
//                    viewHolder.tv_dai_userName.setText(deliveryAddressBean.getUserName());
//                }
//                if (!TextUtils.isEmpty(deliveryAddressBean.getPhone())) {
//                    viewHolder.tv_dai_phone.setText(StringProcessingUtil.setNumFormat(deliveryAddressBean.getPhone()));
//                }
//                String address = "";
//                if (deliveryAddressBean.isDefaultAddress()) {
//                    address += "<font color=\"#28BFA9\">" + mContext.getString(R.string.str_sdaa_default_address) + "</font>";
//                } else {
//                }
//                if (!TextUtils.isEmpty(deliveryAddressBean.getLabel())) {
//                    address += "<font color=\"#28BFA9\">" + "[" + deliveryAddressBean.getLabel() + "]" + "</font>";
//                } else {
//                }
//                if (!TextUtils.isEmpty(deliveryAddressBean.getCity())) {
//                    address += deliveryAddressBean.getCity();
//                }
//                if (!TextUtils.isEmpty(deliveryAddressBean.getAddress())) {
//                    address += deliveryAddressBean.getAddress();
//                }
//                viewHolder.tv_dai_address.setText(Html.fromHtml(address));
//
//                //设置是否选中图标样式
//                if (deliveryAddressBean.isSelected()) {
//                    viewHolder.iv_dai_selectAddress.setImageResource(R.mipmap.icon_address_selected);
//                } else {
//                    viewHolder.iv_dai_selectAddress.setImageResource(R.mipmap.icon_address_uncheck);
//                }
//
//                viewHolder.rl_dai_selectAddress_layout.setOnClickListener(new View.OnClickListener() {
//                    @Override
//                    public void onClick(View view) {
//                        try {
//                            if (deliveryAddressBean != null) {
//                                if (deliveryAddressBean.isSelected()) {
//                                    viewHolder.iv_dai_selectAddress.setImageResource(R.mipmap.icon_address_uncheck);
//                                    deliveryAddressBean.setSelected(false);
//                                } else {
//                                    viewHolder.iv_dai_selectAddress.setImageResource(R.mipmap.icon_address_selected);
//                                    deliveryAddressBean.setSelected(true);
//                                }
////                                LKLogUtil.e("SelectAddress选中了：" + LKJsonUtil.objConversionJsonString(deliveryAddressBean));
//                                Intent intent = new Intent();
//                                intent.putExtra(SelectDeliveryAddressActivity.AddressSelectLogoKey, deliveryAddressBean);
//                                ((SelectDeliveryAddressActivity) mContext).setResult(SelectDeliveryAddressActivity.SelectDeliveryAddressCode, intent);
//                            }
//                            ((SelectDeliveryAddressActivity) mContext).finish();
//                        } catch (Exception e) {
//                            LKLogUtil.e(e.getMessage(), e);
//                        }
//
//
////                        try {
////                            if (deliveryAddressBean != null) {
////                                LKLogUtil.e("SelectAddress选中了：" + LKJsonUtil.objConversionJsonString(deliveryAddressBean));
////                                if(deliveryAddressBean.isSelected()){
////                                    viewHolder.iv_dai_selectAddress.setImageResource(R.mipmap.icon_address_uncheck);
////                                    deliveryAddressBean.setSelected(false);
////                                }else{
////                                    viewHolder.iv_dai_selectAddress.setImageResource(R.mipmap.icon_address_selected);
////                                    deliveryAddressBean.setSelected(true);
////                                }
////                                DeliveryAddressRelatedServer.getInstance().saveDeliveryAddressInfo(deliveryAddressBean);
////                                List<DeliveryAddressBean>  dataListA= GeneralDb.getQueryAll(DeliveryAddressBean.class);
////                                if (dataListA!=null&&dataListA.size()>0){
////                                    for (int j = 0; j <dataListA.size() ; j++) {
////                                        LKLogUtil.e("收货地址全部==="+dataListA.get(j ).getAddress());
////                                    }
////
////                                }
////
////                                List<DeliveryAddressBean>  dataList= GeneralDb.getQueryByWhere(DeliveryAddressBean.class,"isSelected",new Boolean[]{true});
////                                if (dataList!=null&&dataList.size()>0){
////                                    LKLogUtil.e("收货地址==="+dataList.get(0).getAddress());
////                                }
////                            }
////                        } catch (Exception e) {
////                            LKLogUtil.e(e.getMessage(), e);
////                        }
//
//                    }
//                });
//            }
//        }
//    }
//
//    private class ViewHolder {
//
//        private RelativeLayout rl_dai_selectAddress_layout;
//
//        /**
//         * 收货人名称
//         */
//        private TextView tv_dai_userName;
//
//        /**
//         * 收货人电话
//         */
//        private TextView tv_dai_phone;
//
//        /**
//         * 地址信息
//         */
//        private TextView tv_dai_address;
//
//        /**
//         * 选中地址按钮
//         */
//        private ImageView iv_dai_selectAddress;
//    }
//}
